//
//  BaseTableViewController.swift
//  WEIBO_SWIFT
//
//  Created by 岳挺 on 15/6/24.
//  Copyright © 2015年 yueting. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisibleViewDelegate {
    
    //用户登陆标记
    var userLogin = sharedUserAccount?.access_token == nil
    var visibleLoginView :VisibleView?

    override func loadView() {
//        userLogin = sharedUserAccount?.access_token == nil
//        userLogin ? super.loadView() : setVisibleView()
        
        userLogin ? setVisibleView() : super.loadView()
        
        if userLogin == false {
            navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visibleViewRegisterBtnDidClick")
            navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visibleViewLoginBtnDidClick")
        }
    }
    
    func visibleViewLoginBtnDidClick() {
        print(__FUNCTION__)
        
        let vc = OauthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func visibleViewRegisterBtnDidClick() {
        print(__FUNCTION__)
    }
    
    
    func setVisibleView() {
        visibleLoginView = VisibleView()
        visibleLoginView?.delegate = self
        view = visibleLoginView
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }

}
